package dp.mobile.game;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.PointF;

import dp.mobile.glwrapper.GameRenderer;
import dp.mobile.system.Utilities;

public class FloatingText {
	public FloatingText(String text, int tint, int x, int y, long startTime) {
		mText 		= text;
		mTint 		= tint;
		mPosition 	= new PointF(x, y);
		mStartTime 	= startTime;
		mAlive		= true;
		
		mCurrentTime = startTime;
	}
	
	public void update(long time) {
		mCurrentTime += time;
		mPosition.y -= (time * Utilities.FLOATING_TEXT_SPEED) / 1000.0f;
		
		if (mCurrentTime >= mStartTime + Utilities.FLOATING_TEXT_DURAT)
			mAlive = false;
	}
	
	public void draw(GL10 gl) {
		GameRenderer.instance().drawText(gl, mText, mPosition.x, mPosition.y, 1.5f, mTint);
	}
	
	public boolean isAlive() {
		return mAlive;
	}
	
	private long mStartTime;
	private long mCurrentTime;
	private boolean mAlive;
	private int mTint;
	private String mText;
	private PointF mPosition; 
}
